<% 
String mysJDBCDriver = "com.mysql.jdbc.Driver"; 
String mysURL = "jdbc:mysql://mysql2.cs.stonybrook.edu:3306/jedale"; 
String mysUserID = "jedale"; 
String mysPassword = "107200855";
java.sql.Connection conn=null;
  			

		try 
		{
			int custID = (Integer)session.getValue("customerID");
			
        	Class.forName(mysJDBCDriver).newInstance();
			java.util.Properties sysprops=System.getProperties();
			sysprops.put("user",mysUserID);
			sysprops.put("password",mysPassword);
    
			//connect to the database
        	conn=java.sql.DriverManager.getConnection(mysURL,sysprops);
        	System.out.println("Connected successfully to database using JConnect");
       		String ItemID = request.getParameter("itemID");
       		String AucID = request.getParameter("auctionID");
       		String userID = request.getParameter("userId");
        	
       		String ItemName = request.getParameter("ItemName");
       		String ItemDesc = request.getParameter("ItemDesc");
       		String Type = request.getParameter("Type");
       		String Number = request.getParameter("Number");
       		String Inc = request.getParameter("Inc");
       		String Starting = request.getParameter("Starting");
       		String Reserve = request.getParameter("Reserve");
       		String EndTime = request.getParameter("EndTime");
        	
        	
        	java.sql.Statement stmt1=conn.createStatement();
        	
        	stmt1.executeUpdate("INSERT INTO ITEM (ItemID,ItemDescription,Name,ItemType,NumCopies) VALUES(" +ItemID+",'"+ItemDesc+ "','" + ItemName + "','"  + Type + "'," + Number + ")");
        	stmt1.executeUpdate("INSERT INTO Auction (AuctionID,BidIncrement,MinimumBid,Reserve,Copies_Sold,Monitor,ItemID) VALUE ("+AucID + "," + Inc+ ","+Starting+","+Reserve+","+0+","+123456789+","+ItemID+")");
        	stmt1.executeUpdate("INSERT INTO Post(ExpireDate,PostDate,CustomerID,AuctionID) VALUES ('"+EndTime+"',CURRENT_TIMESTAMP,"+userID+","+AucID+ ")" );
        	
        	stmt1.close();

    		response.sendRedirect("AuctionPage.jsp?AuctionID="+AucID);
		} catch(Exception e)
		{
			e.printStackTrace();
			out.print(e.toString());
		}
		finally{
		
			try{conn.close();}catch(Exception ee){};
		}

%>
